#include "music_handler.h"

#include <iostream>
using namespace std;

user_handler::music_handler::~music_handler()
{ }

void user_handler::music_handler::handle_event(
	boost::shared_ptr<network::message> e)
{
	if(e->type == network::RECEIVE) {
		boost::shared_ptr<model::dom> node(e->node);
		if(node->name() != "client") {
			return;
		}
		cout << node->to_string() << endl;
		_music->add_music(node, _sock);
	} else if(e->type == network::DELETE) {
		cout << "deleting a client..." << endl;
		_music->remove_music(_sock);
		boost::shared_ptr<user_handler::music_handler> ptr(_this.lock());
		fire_listener();
		_this.reset();
	}
}

